package net.niufei.study.cpatterns.readwritelock;

import java.util.Random;

public class Writer implements Runnable {
	private final Data data;
	private Random rand = new Random();
	
	public Writer(Data data) {
		this.data = data;
	}

	@Override
	public void run() {
		while(true) {
			try {
				Thread.sleep(rand.nextInt(5000));
				data.write(new String(new char[]{(char)rand.nextInt(95)}));
			} catch (InterruptedException e) {
			}
		}
	}
	
	
}
